*********************************************************************
* The impact of child soldiers on rebel groups' fighting capacities *
*                                                                   *  
* Replication instructions                                          *
*                                                                   *  
* Roos Haer and Tobias Boehmelt                                     *
*                                                                   *
* Stata version: 13.1                                               * 
*                                                                   * 
* November 27, 2014                                                 * 
*********************************************************************

**********************
* Summary statistics *
**********************

use "C:\Users\tbohmelt\Dropbox\Child Soldiers\Final Data\Final Data.dta", clear

sum fightcap_new csindex strengthcent mob_personnel armsproc terrcont ln_rebestimate duration resources conflict2
collin csindex strengthcent mob_personnel armsproc terrcont ln_rebestimate duration resources conflict2

***********
* Table 1 *
***********

tab fightcap_new csindex, chi

************
* Figure 1 *
************

use "C:\Users\tbohmelt\Dropbox\Child Soldiers\Child Data Original\Child Soldiers Final Data.dta" , clear

collapse csdummy, by(ccode)
kountry ccode, from(cown) to(iso3c)
drop ccode
rename csdummy csindex_conflict_final
move  _ISO3C_ csindex_conflict_final
rename  _ISO3C_ ISO
replace ISO="ETH" if ISO==""
generate test=0 
replace test=1 if csindex_conflict_final>0
replace csindex_conflict_final=test
drop test
sort ISO
replace ISO = "YUG" in 63
replace ISO = "ROM" in 55
sort ISO
saveold "C:\Users\tbohmelt\Dropbox\Descriptive.dta", replace

ssc install spmap
ssc install shp2dta

cd "C:\Users\tbohmelt\Dropbox"
shp2dta using world_adm0, data(world-d) coor(world-c) genid(id)
use "C:\Users\tbohmelt\Dropbox\world-d.dta", clear
rename GMI_CNTRY ISO
sort ISO
merge ISO using "C:\Users\tbohmelt\Dropbox\Descriptive.dta", nokeep
replace csindex_conflict_final=0 if csindex_conflict_final==.
drop _merge
spmap csindex_conflict_final using "world-c.dta" if NAME!="Antarctica", id(id) legend(symy(*2) symx(*2) size(*2)) legorder(lohi) clnumber(2)

**************************************************
* Main analyses I - Bivariate probit regressions *
**************************************************

use "C:\Users\tbohmelt\Dropbox\Child Soldiers\Final Data\Final Data.dta", clear

biprobit (fightcap_new=csindex) (csdummy=conflict2), cluster(dyadid) level(90)
preserve
sum conflict2 if e(sample), meanonly
replace conflict2=r(mean)
predict p11, pcond1
tab p11 csindex
drop p11
restore

biprobit (fightcap_new=csindex strengthcent mob_personnel armsproc terrcont) (csdummy=strengthcent mob_personnel armsproc terrcont conflict2), cluster(dyadid) level(90)
preserve
foreach var of varlist strengthcent mob_personnel armsproc terrcont conflict2 {
	sum `var' if e(sample), meanonly
	replace `var' = r(mean)
}
predict p11, pcond1
tab p11 csindex
drop p11
restore

biprobit (fightcap_new=csindex strengthcent mob_personnel armsproc terrcont ln_rebestimate duration resources) (csdummy=strengthcent mob_personnel armsproc terrcont ln_rebestimate duration resources conflict2), cluster(dyadid) level(90)
preserve
foreach var of varlist strengthcent mob_personnel armsproc terrcont ln_rebestimate duration resources conflict2 {
	sum `var' if e(sample), meanonly
	replace `var' = r(mean)
}
predict p11, pcond1
tab p11 csindex
drop p11
restore

*****************************************
* Main analyses II - Probit regressions *
*****************************************

probit fightcap_new csindex strengthcent mob_personnel armsproc terrcont, cluster(dyadid) level(90)
probit fightcap_new csindex strengthcent mob_personnel armsproc terrcont ln_rebestimate duration resources, cluster(dyadid) level(90)
probit fightcap_new csindex strengthcent mob_personnel armsproc terrcont ln_rebestimate duration resources conflict2, cluster(dyadid) level(90)

estsimp probit fightcap_new csindex strengthcent mob_personnel armsproc terrcont, cluster(dyadid) level(90)
setx csindex median strengthcent median mob_personnel median armsproc median terrcont median
simqi, fd(prval(1)) changex(csindex min max) level(90)
simqi, fd(prval(1)) changex(strengthcent min max) level(90)
simqi, fd(prval(1)) changex(mob_personnel min max) level(90)
simqi, fd(prval(1)) changex(armsproc min max) level(90)
simqi, fd(prval(1)) changex(terrcont min max) level(90)
drop in 296/1000
drop b1 b2 b3 b4 b5 b6

probit fightcap_new strengthcent mob_personnel armsproc terrcont, cluster(dyadid) level(90)
lroc, nograph
probit fightcap_new csindex strengthcent mob_personnel armsproc terrcont, cluster(dyadid) level(90)
lroc, nograph

estsimp probit fightcap_new csindex strengthcent mob_personnel armsproc terrcont ln_rebestimate duration resources, cluster(dyadid) level(90)
setx csindex median strengthcent median mob_personnel median armsproc median terrcont median ln_rebestimate median duration median resources median
simqi, fd(prval(1)) changex(csindex min max) level(90)
simqi, fd(prval(1)) changex(strengthcent min max) level(90)
simqi, fd(prval(1)) changex(mob_personnel min max) level(90)
simqi, fd(prval(1)) changex(armsproc min max) level(90)
simqi, fd(prval(1)) changex(terrcont min max) level(90)
simqi, fd(prval(1)) changex(ln_rebestimate min max) level(90)
simqi, fd(prval(1)) changex(duration min max) level(90)
simqi, fd(prval(1)) changex(resources min max) level(90)
drop in 296/1000
drop b1 b2 b3 b4 b5 b6 b7 b8 b9

probit fightcap_new strengthcent mob_personnel armsproc terrcont ln_rebestimate duration resources, cluster(dyadid) level(90)
lroc, nograph
probit fightcap_new csindex strengthcent mob_personnel armsproc terrcont ln_rebestimate duration resources, cluster(dyadid) level(90)
lroc, nograph

estsimp probit fightcap_new csindex strengthcent mob_personnel armsproc terrcont ln_rebestimate duration resources conflict2, cluster(dyadid) level(90)
setx csindex median strengthcent median mob_personnel median armsproc median terrcont median ln_rebestimate median duration median resources median conflict2 median
simqi, fd(prval(1)) changex(csindex min max) level(90)
simqi, fd(prval(1)) changex(strengthcent min max) level(90)
simqi, fd(prval(1)) changex(mob_personnel min max) level(90)
simqi, fd(prval(1)) changex(armsproc min max) level(90)
simqi, fd(prval(1)) changex(terrcont min max) level(90)
simqi, fd(prval(1)) changex(ln_rebestimate min max) level(90)
simqi, fd(prval(1)) changex(duration min max) level(90)
simqi, fd(prval(1)) changex(resources min max) level(90)
simqi, fd(prval(1)) changex(conflict2 min max) level(90)
drop in 296/1000
drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10

probit fightcap_new strengthcent mob_personnel armsproc terrcont ln_rebestimate duration resources conflict2, cluster(dyadid) level(90)
lroc, nograph
probit fightcap_new csindex strengthcent mob_personnel armsproc terrcont ln_rebestimate duration resources conflict2, cluster(dyadid) level(90)
lroc, nograph

twoway (rcapsym low_bound upp_bound covariate if id_law==1, lcolor(black) lpattern(dash) horizontal mcolor(black) msize(vsmall) msymbol(diamond_hollow)) (scatter covariate first_diff if id_law==1, mcolor(black) msize(medlarge) msymbol(x)), xtitle(First Difference) xline(0, lpattern(solid) lcolor(gs9)) legend(off) scheme(lean1) name(size1, replace)
twoway (rcapsym low_bound upp_bound covariate if id_law==2, lcolor(black) lpattern(dash) horizontal mcolor(black) msize(vsmall) msymbol(diamond_hollow)) (scatter covariate first_diff if id_law==2, mcolor(black) msize(medlarge) msymbol(x)), xtitle(First Difference) xline(0, lpattern(solid) lcolor(gs9)) legend(off) scheme(lean1) name(size2, replace)
twoway (rcapsym low_bound upp_bound covariate if id_law==3, lcolor(black) lpattern(dash) horizontal mcolor(black) msize(vsmall) msymbol(diamond_hollow)) (scatter covariate first_diff if id_law==3, mcolor(black) msize(medlarge) msymbol(x)), xtitle(First Difference) xline(0, lpattern(solid) lcolor(gs9)) legend(off) scheme(lean1) name(size3, replace)

graph combine size1 size2 size3, xcommon scheme(lean1)

*********************
* Robustness checks *
*********************

biprobit (fightcap_new=csindex strengthcent mob_personnel armsproc terrcont ln_rebestimate duration resources ln_gdp_pc ln_edu ln_population polity2 lmtnest ethfrac relfrac) (csdummy=strengthcent mob_personnel armsproc terrcont ln_rebestimate duration resources conflict2 ln_gdp_pc ln_edu ln_population polity2 lmtnest ethfrac relfrac conflict2), cluster(dyadid) level(90)
probit fightcap_new csindex strengthcent mob_personnel armsproc terrcont ln_rebestimate duration resources conflict2 ln_gdp_pc ln_edu ln_population polity2 lmtnest ethfrac relfrac conflict2, cluster(dyadid) level(90)

biprobit (fightcap_new=csindex terrcont strengthcent mob_personnel armsproc duration ln_rebestimate resources rebexpart rebelsupport transconstsupp_new) (csdummy=terrcont strengthcent mob_personnel duration ln_rebestimate resources conflict1-conflict8), cluster(dyadid)
biprobit (fightcap_new=csindex terrcont strengthcent mob_personnel armsproc duration ln_rebestimate resources rebexpart rebelsupport transconstsupp_new) (csdummy=terrcont strengthcent mob_personnel duration ln_rebestimate resources conflict2), cluster(dyadid)

generate where = -0.2
generate pipe = "|"

probit fightcap_new c.csindex##c.ln_rebestimate strengthcent mob_personnel armsproc terrcont duration resources conflict2, cluster(dyadid) level(90)
sum ln_rebestimate if e(sample)
margins, dydx(csindex) at(ln_rebestimate =(4.50(0.5)12)) vsquish
marginsplot, recast(line) recastci(rline) yline(0) level(90) scheme(lean1) aspectratio(1) addplot(scatter where ln_rebestimate, scheme(lean1) ms(none) mlabel(pipe) mlabpos(0)) legend(off)

tab fightcap_new if ln_rebestimate>8
tab fightcap_new if ln_rebestimate<8.1
tab fightcap_distinction csdummy

ttest fightcap_new, level(90) by (fightcap_distinction)

oprobit fightcap csindex strengthcent mob_personnel armsproc terrcont, cluster(dyadid) level(90)
oprobit fightcap csindex strengthcent mob_personnel armsproc terrcont ln_rebestimate duration resources, cluster(dyadid) level(90)
